/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fix.it.source.fixit;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Biserka
 */
@Entity
@Table(name = "STREET")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Street.findAll", query = "SELECT s FROM Street s"),
    @NamedQuery(name = "Street.findById", query = "SELECT s FROM Street s WHERE s.id = :id"),
    @NamedQuery(name = "Street.findByName", query = "SELECT s FROM Street s WHERE s.name = :name"),
    @NamedQuery(name = "Street.findByNumber", query = "SELECT s FROM Street s WHERE s.number = :number")})
public class Street implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "streetid")
    private Collection<Problem> problemCollection;
    @OneToMany(mappedBy = "streetid")
    private Collection<Authority> authorityCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "NUMBER")
    private String number;
    @JoinColumn(name = "MUNICIPALITYID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Municipality municipalityid;

    public Street() {
    }

    public Street(Long id) {
        this.id = id;
    }

    public Street(Long id, String name, String number) {
        this.id = id;
        this.name = name;
        this.number = number;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Municipality getMunicipalityid() {
        return municipalityid;
    }

    public void setMunicipalityid(Municipality municipalityid) {
        this.municipalityid = municipalityid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Street)) {
            return false;
        }
        Street other = (Street) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fix.it.source.fixit.Street[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<Authority> getAuthorityCollection() {
        return authorityCollection;
    }

    public void setAuthorityCollection(Collection<Authority> authorityCollection) {
        this.authorityCollection = authorityCollection;
    }

    @XmlTransient
    public Collection<Problem> getProblemCollection() {
        return problemCollection;
    }

    public void setProblemCollection(Collection<Problem> problemCollection) {
        this.problemCollection = problemCollection;
    }
    
}
